#######################################################################################
# Sample make file. It is mainly used under MinGW32 environment.
# NOTES:
# 1. When exe "make", if you don't specify the target, the first target will be executed
# 2. BE SURE to provide the dependencies for each *.o object's generation
########################################################################################
CXX =		gcc
INCLUDES +=	-I"C:\MiniGW\include" \
		-I"C:\MiniGW\include\c++\3.4.5" \
		-I"C:\MiniGW\include\c++\3.4.5\backward" \
		-I"C:\MiniGW\include\c++\3.4.5\mingw32" \
		-I"C:\MiniGW\lib\gcc\mingw32\3.4.5\include"

# -g    means to generate the debug information
# -Wall means to generate the extra warning information for virtual table, and so on
# -M    means to generate the information about the relationship between file, for example
#       the source files that the object file relys on
# -MD   the same with -M but the generated file-relation file will be stored in *.d file
CFLAGS =	-Wall -g $(INCLUDES) -MD

# Whether to optimize, can be O0, O1, O2, O3, O0 means no optimization
CFLAGS +=	-O2 -static
CPPFLAGS =	$(CFLAGS)

LIBS =

OBJECTS =	bigint.o \
		rsa.o \
		getopt.o \
		tool.o

getopt.o:	getopt.c
	$(CXX) $(INCLUDES) $(CFLAGS) -c $^ -o $@

bigint.o:	bigint.c
	$(CXX) $(INCLUDES) $(CFLAGS) -c $^ -o $@

rsa.o:		rsa.c
	$(CXX) $(INCLUDES) $(CFLAGS) -c $^ -o $@

tool.o:		tool.c
	$(CXX) $(INCLUDES) $(CFLAGS) -c $^ -o $@

main.o:		main.c
	$(CXX) $(INCLUDES) $(CFLAGS) -c $^ -o $@

OUTPUT =	../bin/rsa.exe
LIBOUTPUT =	../lib/librsa.a

all: $(OBJECTS) main.o
	$(CXX) $(LIBS) -o $(OUTPUT) $^
	$(AR) rcs $(LIBOUTPUT) $^

clean:
	-rm -f *.o *.d *.~*